unit NamedQueryOperate;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Vcl.StdCtrls, Vcl.Buttons,
  Vcl.ExtCtrls, Vcl.DBCtrls, Vcl.Grids, Vcl.DBGrids, kbmMemTable,
  kbmMWCustomConnectionPool, kbmMWCustomDataset, kbmMWClientDataset;

type
  TfrmNamedQuery = class(TForm)
    dbgrd1: TDBGrid;
    dbnvgr1: TDBNavigator;
    btnUpdate: TBitBtn;
    ds1: TDataSource;
    kbmMWClientQuery1: TkbmMWClientQuery;
    btnOpen: TBitBtn;
    kbmMWClientTransactionResolver1: TkbmMWClientTransactionResolver;
    procedure FormCreate(Sender: TObject);
    procedure btnOpenClick(Sender: TObject);
    procedure btnUpdateClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmNamedQuery: TfrmNamedQuery;

implementation

{$R *.dfm}
uses DMClient;

procedure TfrmNamedQuery.btnOpenClick(Sender: TObject);
begin
   if kbmMWClientQuery1.Active then  kbmMWClientQuery1.Close;
   kbmMWClientQuery1.Open;
   dbgrd1.Refresh;
end;

procedure TfrmNamedQuery.btnUpdateClick(Sender: TObject);
begin
  //kbmMWClientTransactionResolver1.Resolve([kbmMWClientQuery1]);

  kbmMWClientQuery1.Resolve();
end;

procedure TfrmNamedQuery.FormCreate(Sender: TObject);
begin
 with kbmMWClientQuery1 do
  begin
    Client := dtmdlClientLink.kbmscLink;
    ConnectionPool := dtmdlClientLink.kbmccplLink;
    DefaultFormat := dtmdlClientLink.kbmwbnrystrmfrmtLink;
    TransportStreamFormat := dtmdlClientLink.kbmwbnrystrmfrmtLink;

    QueryService := 'DataOperate';
    QueryServiceVersion := '1.0';
    SessionName := 'demo';
    LoadedCompletely := True;
    KeyFields := '*';

    Query.Clear;
    Query.Text:='@kbmwndcqryTest';
    //Query.Text:='select  * from test order by user_id';
  end;

  with kbmMWClientTransactionResolver1 do
  begin
    Client := dtmdlClientLink.kbmscLink;
    ConnectionPool := dtmdlClientLink.kbmccplLink;
    TransportStreamFormat := dtmdlClientLink.kbmwbnrystrmfrmtLink;

    QueryService := 'DataOperate';
    QueryServiceVersion := '1.0';
  end;


end;

end.
